package com.trela.paymeontime.web.controllers;

import java.util.HashMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.trela.paymeontime.web.Routes;
import com.trela.paymeontime.web.model.UserSettings;
import com.trela.paymeontime.web.services.PaymentsService;


@Controller
@RequestMapping(Routes.Main.PREFIX)
public class MainController {

    @Resource
    private PaymentsService paymentsService;

    @Resource
    private UserSettings userSettings;
    
    @RequestMapping(Routes.Main.INDEX)
    public ModelAndView index(HttpServletRequest  request) {
        log.info("Display dshboard");
        HashMap<String, Object> model = new HashMap<>();
        
        model.put("paymentsContext", paymentsService.createPaymentContext(userSettings) );
        
        return new ModelAndView("index", model);
    }
}